package com.bw.medical.controller;

import java.util.Arrays;
import java.util.Map;

import com.bw.medical.vo.HospitalVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bw.medical.entity.TbHospitalEntity;
import com.bw.medical.service.TbHospitalService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 医院表 
 *
 * @author wj
 * @email sunlightcs@gmail.com
 * @date 2021-08-14 18:10:33
 */
@RestController
@RequestMapping("medical/tbhospital")
public class TbHospitalController {
    @Autowired
    private TbHospitalService tbHospitalService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, @RequestParam("hospitalName") String hospitalName){
        PageUtils page = tbHospitalService.queryPage(params,hospitalName);
        System.out.println((String) params.get("hospitalName"));
        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{hospitalId}")
    public R info(@PathVariable("hospitalId") Integer hospitalId){
		TbHospitalEntity tbHospital = tbHospitalService.getById(hospitalId);

        return R.ok().put("tbHospital", tbHospital);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TbHospitalEntity tbHospital){
		tbHospitalService.save(tbHospital);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TbHospitalEntity tbHospital){
		tbHospitalService.updateById(tbHospital);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] hospitalIds){
		tbHospitalService.removeByIds(Arrays.asList(hospitalIds));

        return R.ok();
    }

}
